package concurrent.spring.concurrent;


import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;

public interface ListenableFuture<T> extends Future<T> {

    void addCallback(ListenableFutureCallback<? super T> callback);

    void addCallable(SuccessCallback<? super T> callback, FailureCallback failureCallback);


    default CompletableFuture<T> completable() {
        CompletableFuture<T> completable = new DelegatingCompletableFuture<>(this);
        addCallable(completable::complete, completable::completeExceptionally);
        return completable;
    }


}
